import {defHttp} from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";

const { createConfirm } = useMessage();

enum Api {
  list = '/oa/oaEmployeeInfo/list',
  save='/oa/oaEmployeeInfo/add',
  edit='/oa/oaEmployeeInfo/edit',
  deleteOne = '/oa/oaEmployeeInfo/delete',
  deleteBatch = '/oa/oaEmployeeInfo/deleteBatch',
  importExcel = '/oa/oaEmployeeInfo/importExcel',
  exportXls = '/oa/oaEmployeeInfo/exportXls',
  oaOvertimeRecordList = '/oa/oaEmployeeInfo/listOaOvertimeRecordByMainId',
  oaOvertimeRecordSave='/oa/oaEmployeeInfo/addOaOvertimeRecord',
  oaOvertimeRecordEdit='/oa/oaEmployeeInfo/editOaOvertimeRecord',
  oaOvertimeRecordDelete = '/oa/oaEmployeeInfo/deleteOaOvertimeRecord',
  oaOvertimeRecordDeleteBatch = '/oa/oaEmployeeInfo/deleteBatchOaOvertimeRecord',
  oaAttendanceRecordList = '/oa/oaEmployeeInfo/listOaAttendanceRecordByMainId',
  oaAttendanceRecordSave='/oa/oaEmployeeInfo/addOaAttendanceRecord',
  oaAttendanceRecordEdit='/oa/oaEmployeeInfo/editOaAttendanceRecord',
  oaAttendanceRecordDelete = '/oa/oaEmployeeInfo/deleteOaAttendanceRecord',
  oaAttendanceRecordDeleteBatch = '/oa/oaEmployeeInfo/deleteBatchOaAttendanceRecord',
  oaMonthlyAttendanceList = '/oa/oaEmployeeInfo/listOaMonthlyAttendanceByMainId',
  oaMonthlyAttendanceSave='/oa/oaEmployeeInfo/addOaMonthlyAttendance',
  oaMonthlyAttendanceEdit='/oa/oaEmployeeInfo/editOaMonthlyAttendance',
  oaMonthlyAttendanceDelete = '/oa/oaEmployeeInfo/deleteOaMonthlyAttendance',
  oaMonthlyAttendanceDeleteBatch = '/oa/oaEmployeeInfo/deleteBatchOaMonthlyAttendance',
  oaMonthlyOvertimeList = '/oa/oaEmployeeInfo/listOaMonthlyOvertimeByMainId',
  oaMonthlyOvertimeSave='/oa/oaEmployeeInfo/addOaMonthlyOvertime',
  oaMonthlyOvertimeEdit='/oa/oaEmployeeInfo/editOaMonthlyOvertime',
  oaMonthlyOvertimeDelete = '/oa/oaEmployeeInfo/deleteOaMonthlyOvertime',
  oaMonthlyOvertimeDeleteBatch = '/oa/oaEmployeeInfo/deleteBatchOaMonthlyOvertime',
  oaPaidWagesList = '/oa/oaEmployeeInfo/listOaPaidWagesByMainId',
  oaPaidWagesSave='/oa/oaEmployeeInfo/addOaPaidWages',
  oaPaidWagesEdit='/oa/oaEmployeeInfo/editOaPaidWages',
  oaPaidWagesDelete = '/oa/oaEmployeeInfo/deleteOaPaidWages',
  oaPaidWagesDeleteBatch = '/oa/oaEmployeeInfo/deleteBatchOaPaidWages',
}
/**
 * 导出api
 * @param params
 */
export const getExportUrl = Api.exportXls;

/**
 * 导入api
 */
export const getImportUrl = Api.importExcel;
/**
 * 列表接口
 * @param params
 */
export const list = (params) =>
  defHttp.get({url: Api.list, params});

/**
 * 删除单个
 */
export const deleteOne = (params,handleSuccess) => {
  return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const batchDelete = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const saveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.edit : Api.save;
  return defHttp.post({url: url, params});
}
/**
 * 列表接口
 * @param params
 */
export const oaOvertimeRecordList = (params) => {
  if(params['employeeInfoId']){
    return defHttp.get({url: Api.oaOvertimeRecordList, params});
  }
  return Promise.resolve({});
}


/**
 * 删除单个
 */
export const oaOvertimeRecordDelete = (params,handleSuccess) => {
  return defHttp.delete({url: Api.oaOvertimeRecordDelete, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const oaOvertimeRecordDeleteBatch = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.oaOvertimeRecordDeleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const  oaOvertimeRecordSaveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.oaOvertimeRecordEdit : Api.oaOvertimeRecordSave;
  return defHttp.post({url: url, params});
}
/**
 * 导入
 */
export const oaOvertimeRecordImportUrl = '/oa/oaEmployeeInfo/importOaOvertimeRecord'

/**
 * 导出
 */
export const oaOvertimeRecordExportXlsUrl = '/oa/oaEmployeeInfo/exportOaOvertimeRecord'
/**
 * 列表接口
 * @param params
 */
export const oaAttendanceRecordList = (params) => {
  if(params['employeeInfoId']){
    return defHttp.get({url: Api.oaAttendanceRecordList, params});
  }
  return Promise.resolve({});
}


/**
 * 删除单个
 */
export const oaAttendanceRecordDelete = (params,handleSuccess) => {
  return defHttp.delete({url: Api.oaAttendanceRecordDelete, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const oaAttendanceRecordDeleteBatch = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.oaAttendanceRecordDeleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const  oaAttendanceRecordSaveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.oaAttendanceRecordEdit : Api.oaAttendanceRecordSave;
  return defHttp.post({url: url, params});
}
/**
 * 导入
 */
export const oaAttendanceRecordImportUrl = '/oa/oaEmployeeInfo/importOaAttendanceRecord'

/**
 * 导出
 */
export const oaAttendanceRecordExportXlsUrl = '/oa/oaEmployeeInfo/exportOaAttendanceRecord'
/**
 * 列表接口
 * @param params
 */
export const oaMonthlyAttendanceList = (params) => {
  if(params['employeeInfoId']){
    return defHttp.get({url: Api.oaMonthlyAttendanceList, params});
  }
  return Promise.resolve({});
}


/**
 * 删除单个
 */
export const oaMonthlyAttendanceDelete = (params,handleSuccess) => {
  return defHttp.delete({url: Api.oaMonthlyAttendanceDelete, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const oaMonthlyAttendanceDeleteBatch = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.oaMonthlyAttendanceDeleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const  oaMonthlyAttendanceSaveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.oaMonthlyAttendanceEdit : Api.oaMonthlyAttendanceSave;
  return defHttp.post({url: url, params});
}
/**
 * 导入
 */
export const oaMonthlyAttendanceImportUrl = '/oa/oaEmployeeInfo/importOaMonthlyAttendance'

/**
 * 导出
 */
export const oaMonthlyAttendanceExportXlsUrl = '/oa/oaEmployeeInfo/exportOaMonthlyAttendance'
/**
 * 列表接口
 * @param params
 */
export const oaMonthlyOvertimeList = (params) => {
  if(params['employeeInfoId']){
    return defHttp.get({url: Api.oaMonthlyOvertimeList, params});
  }
  return Promise.resolve({});
}


/**
 * 删除单个
 */
export const oaMonthlyOvertimeDelete = (params,handleSuccess) => {
  return defHttp.delete({url: Api.oaMonthlyOvertimeDelete, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const oaMonthlyOvertimeDeleteBatch = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.oaMonthlyOvertimeDeleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const  oaMonthlyOvertimeSaveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.oaMonthlyOvertimeEdit : Api.oaMonthlyOvertimeSave;
  return defHttp.post({url: url, params});
}
/**
 * 导入
 */
export const oaMonthlyOvertimeImportUrl = '/oa/oaEmployeeInfo/importOaMonthlyOvertime'

/**
 * 导出
 */
export const oaMonthlyOvertimeExportXlsUrl = '/oa/oaEmployeeInfo/exportOaMonthlyOvertime'
/**
 * 列表接口
 * @param params
 */
export const oaPaidWagesList = (params) => {
  if(params['employeeInfoId']){
    return defHttp.get({url: Api.oaPaidWagesList, params});
  }
  return Promise.resolve({});
}


/**
 * 删除单个
 */
export const oaPaidWagesDelete = (params,handleSuccess) => {
  return defHttp.delete({url: Api.oaPaidWagesDelete, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const oaPaidWagesDeleteBatch = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.oaPaidWagesDeleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const  oaPaidWagesSaveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.oaPaidWagesEdit : Api.oaPaidWagesSave;
  return defHttp.post({url: url, params});
}
/**
 * 导入
 */
export const oaPaidWagesImportUrl = '/oa/oaEmployeeInfo/importOaPaidWages'

/**
 * 导出
 */
export const oaPaidWagesExportXlsUrl = '/oa/oaEmployeeInfo/exportOaPaidWages'
